module exp2(
	input wire[7:0] mode_choose,
	input wire[7:0] input_data,
	output reg[11:0] led_out
	);
	wire[11:0] temp_out;
	wire[2:0] exp2_1_out;
	wire[7:0] exp2_2_out;
	wire exp2_3_out;
	wire[2:0] exp2_4_out;
	wire[4:0] exp2_5_out;
	wire[4:0] exp2_6_out;
	reg[7:0] is_enable;
	integer index;	
	encode_83 exp2_1(.data_in(input_data[7:0]),.data_out(exp2_1_out[2:0]),.enable(is_enable[0]));
	decode_38 exp2_2(.data_in(input_data[2:0]),.data_out(exp2_2_out[7:0]),.enable(is_enable[1]));
	mux4_to_1 exp2_3(.input_1(input_data[0]),.input_2(input_data[1]),.input_3(input_data[2]),.input_4(input_data[3]),.s1(input_data[4]),.s2(input_data[5]),.output_data(exp2_3_out),.enable(is_enable[2]));
	compare_4 exp2_4(.x(input_data[3:0]),.y(input_data[7:4]),.data_out(exp2_4_out),.enable(is_enable[3]));
	add_4 exp2_5(.x (input_data[3:0]),.y (input_data[7:4]),.out(exp2_5_out[3:0]),.CF(exp2_5_out[4]),.enable(is_enable[4]));
	minus_4 exp2_6(.x (input_data[3:0]),.y (input_data[7:4]),.out(exp2_6_out[3:0]),.CF(exp2_6_out[4]),.enable(is_enable[5]));
	mux8_to_1 exp2_7();
	always @(mode_choose) begin
		is_enable = 0;
		case(mode_choose)
		8'b00000000:is_enable = 0;
		8'b00000001:is_enable[0] = 1;
		8'b00000010:is_enable[1] = 1;
		8'b00000100:is_enable[2] = 1;
		8'b00001000:is_enable[3] = 1;
		8'b00010000:is_enable[4] = 1;
		8'b00100000:is_enable[5] = 1;
		endcase
	end
	
	always @(exp2_1_out or exp2_2_out or exp2_3_out or exp2_4_out or exp2_5_out or exp2_6_out) begin
		led_out = 12'b111111111111;
		if (is_enable[0]==1)
			for (index=0;index<3;index =index+1) begin
				led_out[index] = ~(exp2_1_out[index]);
			end
		else if(is_enable[1]==1)
			for (index=0;index<8;index =index+1) begin
				led_out[index] = ~(exp2_2_out[index]);
			end
		else if (is_enable[2]==1)
			led_out[0] = ~(exp2_3_out);
		else if(is_enable[3]==1)
			for (index=0;index<3;index =index+1) begin
				led_out[index] = ~(exp2_4_out[index]);
			end
		else if(is_enable[4]==1)
			for (index=0;index<5;index =index+1) begin
				led_out[index] = ~(exp2_5_out[index]);
			end
		else if(is_enable[5]==1)
			for (index=0;index<5;index =index+1) begin
				led_out[index] = ~(exp2_6_out[index]);
			end
		else
			led_out = 12'b111111111111;
	end
endmodule
